<?php
try{
    include '../ini.php';
   
    unset($_SESSION['cart'][$_GET['id']][$_GET['k']]);
    if($_SESSION['cart'][$_GET['id']]==NULL){
        unset($_SESSION['cart'][$_GET['id']]);
    }
    $sum=0;
    foreach($_SESSION['cart'] as $value){
        foreach($value as $k=>$v){
            $sum+=$v['into_money'];
        }
    }
    $_SESSION['sum_of_money']=$sum;
    if($_SESSION['cart'] == NULL){
        unset($_SESSION['sum_of_money']);
    }
    if(empty($_SERVER['HTTP_REFERER'])){
        header('Location: /');
    }else{
        header("Location: ".$_SERVER['HTTP_REFERER']);
    }
}catch(Exception $e){
    $dbh=NULL;
    $_SESSION['msg']=$e->getMessage();
    $_SESSION['type_msg']='error';
    if(empty($_SERVER['HTTP_REFERER'])){
        header('Location: /');
    }else{
        header("Location: ".$_SERVER['HTTP_REFERER']);
    }
}